import request from '../utils/request'
import { Button } from 'antd'
import localStorage from '../utils/localStorage'

function Test() {
  // 查看环境变量
  console.log(import.meta.env)

  // 测试 localStorage
  const handleClick = (type: number) => {
    if (type === 1) {
      localStorage.set('username', 'cc')
      localStorage.set('user', { id: 1001, name: 'chanchaw' })
    }

    if (type === 2) {
      const a = localStorage.get('username')
      const b = localStorage.get('user')
      console.log('a:', a, 'b:', b)
    }

    if (type === 3) localStorage.remove('username')
    if (type === 4) localStorage.clear()
  }
  request
    .get<string>('/test/getJavaDate')
    .then(res => {
      console.log(res)
    })
    .catch(err => console.log(err))

  return (
    <div>
      <Button onClick={() => handleClick(1)}>新增</Button>
      <Button onClick={() => handleClick(2)}>获取</Button>
      <Button onClick={() => handleClick(3)}>移除</Button>
      <Button onClick={() => handleClick(4)}>清除</Button>
    </div>
  )
}

export default Test
